package org.biloxi.commands.changephase;

import org.biloxi.commands.CommandRepository;
import org.biloxi.commands.impl.CommandImpl;
import org.biloxi.model.GameState.Phase;
import org.biloxi.model.mutable.GameStateMutable;

public class ChangePhase extends CommandImpl<ChangePhase.Options, ChangePhase.Result> {
	
	static public class Options {
		public final Phase nextPhase;

		public Options(Phase nextPhase) {
			this.nextPhase = nextPhase;
		}

		@Override
		public String toString() {
			return "ChangePhase.Options: \n"+
						"\tnextPhase = "+nextPhase.toString()+"\n";
		}
		
		
	}
	static public class Result {
		public final Phase phase;
		public final Phase previousPhase;

		public Result(Phase phase, Phase previousPhase) {
			this.phase = phase;
			this.previousPhase = previousPhase;
		}
	}
	
	public ChangePhase(CommandRepository cr) {
		super(cr);
	}
	
	@Override
	protected Result executeImpl(Options o, GameStateMutable gameState) {
		Phase curPhase = gameState.getPhase();
		gameState.setPhase(o.nextPhase);
		return new Result(o.nextPhase, curPhase);
	}

}
